package cn.tedu.spring.life;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * Created by IntelliJ IDEA.
 *
 * @author zq
 * @version 1.0
 * @create 2024-08-03 9:23
 * @since jdk1.8
 */
@Component
public class Life {
    private String meaning;

    public Life() {
        System.out.println("1无参构造Life()");
    }

    @Value("生命的意义在于运动")
    public void setMeaning(String meaning) {
        this.meaning = meaning;
        System.out.println("2set方法初始化");
    }

    @PostConstruct
    public void init() {
        System.out.println("3初始化init()");
    }

    @PreDestroy
    public void destroy() {
        System.out.println("5销毁destroy()");
    }
}
